home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MPW C++ / MPW C++ 3.1 / Interfaces / CIncludes / fstream.h next >
Text File  |  1990-09-11  |  3KB  |  107 lines

  1. /*ident    "@(#)ctrans:incl/fstream.h    1.1.2.3" */
  2. /**************************************************************************
  3.                         Copyright (c) 1984 AT&T
  4.                           All Rights Reserved   
  5.  
  6.         THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  7.       
  8.         The copyright notice above does not evidence any        
  9.         actual or intended publication of such source code.
  10.  
  11. *****************************************************************************/
  12. #ifndef __FSTREAM__
  13. #define __FSTREAM__
  14.  
  15. #include <iostream.h>
  16.  
  17. class  filebuf : public streambuf {    /* a stream buffer for files */
  18. public:
  19.             filebuf() ;
  20.             filebuf(int fd);
  21.             filebuf(int fd, char*  p, int l) ;
  22.  
  23.     int        is_open() { return opened ; }
  24.     int        fd() { return xfd ; }
  25.     filebuf*    open(const char *name, int om/*, int prot=0664*/); // deleted for Macintosh
  26.     filebuf*    attach(int fd) ;
  27.     filebuf*     close() ;
  28.             ~filebuf() ;
  29. public: /* virtuals */
  30.     virtual int    overflow(int=EOF);
  31.     virtual int    underflow();
  32.     virtual int    sync() ;
  33.     virtual streampos
  34.             seekoff(streamoff,seek_dir,int) ;
  35.     virtual streambuf*
  36.             setbuf(char*  p, int len) ;
  37. protected:
  38.     int        xfd;    
  39.     int        mode ;
  40.     char        opened;
  41.     streampos    last_seek ;
  42.     char*         in_start;
  43.     int        last_op();
  44.     char        lahead[2] ;
  45. };
  46.  
  47. class fstreambase : virtual public ios { 
  48. public:
  49.             fstreambase() ;
  50.     
  51.             fstreambase(const char* name, 
  52.                     int mode/*,int prot=0664*/) ; // deleted for Macintosh
  53.             fstreambase(int fd) ;
  54.             fstreambase(int fd, char*  p, int l) ;
  55.             ~fstreambase() ;
  56.     void        open(const char* name, int mode/*, int prot=0664*/) ; // deleted for Macintosh
  57.     void        attach(int fd);
  58.     void        close() ;
  59.     void        setbuf(char*  p, int l) ;
  60.     filebuf*    rdbuf() { return &buf ; }
  61. private:
  62.     filebuf        buf ;
  63. protected:
  64.     void        verify(int) ;
  65. } ;
  66.  
  67. class ifstream : public fstreambase, public istream {
  68. public:
  69.             ifstream() ;
  70.             ifstream(const char* name, 
  71.                     int mode=ios::in /*,int prot=0664*/) ; // for Macintosh
  72.             ifstream(int fd) ;
  73.             ifstream(int fd, char*  p, int l) ;
  74.             ~ifstream() ;
  75.  
  76.     filebuf*    rdbuf() { return fstreambase::rdbuf(); }
  77.     void        open(const char* name, int mode=ios::in/*, int prot=0664*/) ; // deleted for Macintosh
  78. } ;
  79.  
  80. class ofstream : public fstreambase, public ostream {
  81. public:
  82.             ofstream() ;
  83.             ofstream(const char* name, 
  84.                     int mode=ios::out/*,int prot=0664*/) ; // for Macintosh
  85.             ofstream(int fd) ;
  86.             ofstream(int fd, char*  p, int l) ;
  87.             ~ofstream() ;
  88.  
  89.     filebuf*    rdbuf() { return fstreambase::rdbuf(); }
  90.     void        open(const char* name, int mode=ios::out /*, int prot=0664*/) ; // deleted for Macintosh
  91. } ;
  92.  
  93. class fstream : public fstreambase, public iostream {
  94. public:
  95.             fstream() ;
  96.     
  97.             fstream(const char* name, 
  98.                     int mode/*,int prot=0664*/) ; // for Macintosh
  99.             fstream(int fd) ;
  100.             fstream(int fd, char*  p, int l) ;
  101.             ~fstream() ;
  102.     filebuf*    rdbuf() { return fstreambase::rdbuf(); }
  103.     void        open(const char* name, int mode/*, int prot=0664*/) ; // deleted for Macintosh
  104. } ;
  105.  
  106. #endif
  107.